<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main2"/>
    <g:set var="entityName" value="${message(code: 'opportunity.label', default: 'Opportunity')}"/>
    <title>商机详情</title>
</head>


<body>
<div class="main-body">
    <div class="page-wrapper">
        <!-- Page-header start -->
        <div class="page-header">
            <div class="page-header-title">
                <h4>商机详情</h4>
            </div>

            <div class="page-header-breadcrumb">
                <ul class="breadcrumb-title">
                    <li class="breadcrumb-item">
                        <a href="/salesDashboard/index">
                            <i class="icofont icofont-home"></i>
                        </a>
                    </li>
                    <li class="breadcrumb-item">
                        <g:link controller="opportunity" action="index">商机列表</g:link>
                    </li>
                    <li class="breadcrumb-item">商机详情</li>
                </ul>
            </div>
        </div>
        <!-- Page-header end -->
        <!-- Page-body start -->
        <div class="page-body">
            <g:if test="${flash.message}">
                <div class="message alert alert-info" role="status">${flash.message}
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">×</span></button>
                </div>
            </g:if>

        <!-- Hover table card start -->
            <div class="card">
                <div class="card-header">
                    <h5>商机详情</h5>

                    <div class="card-header-right">
                        <g:link action="edit" resource="${this.opportunity}" data-toggle="tooltip" data-placement="top" title="" data-original-title="编辑">
                            <i class="icofont icofont-edit"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>

                <div class="card-block">

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">商机详情号</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.opportunity?.serialNumber}</div>
                        </div>
                        <label class="col-md-2 col-form-label">阶段</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.opportunity?.stage?.name}</div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">金额（元）</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.opportunity?.amount}</div>
                        </div>
                        <label class="col-md-2 col-form-label">几率（%）</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.opportunity?.probability}</div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">产品</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.opportunity?.product?.name}</div>
                        </div>
                        <label class="col-md-2 col-form-label">采购方法</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.opportunity?.purchasingMethod?.name}</div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">客户</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.opportunity?.account?.name}</div>
                        </div>
                        <label class="col-md-2 col-form-label">分级</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.opportunity?.account?.level?.name}</div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">商机发现时间</label>

                        <div class="col-md-3">
                            <div class="form-control-static">
                                <g:formatDate date="${this.opportunity?.startTime}"
                                              format="yyyy-MM-dd HH:mm:ss"></g:formatDate>
                            </div>
                        </div>
                        <label class="col-md-2 col-form-label">客户预计采购时间</label>

                        <div class="col-md-3">
                            <div class="form-control-static">
                                <g:formatDate date="${this.opportunity?.endTime}"
                                              format="yyyy-MM-dd HH:mm:ss"></g:formatDate>
                            </div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">商机描述</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.opportunity?.memo}</div>
                        </div>
                    </div>

                </div>

            </div>
            <!-- Hover table card end -->
            <div class="card">
                <div class="card-header">
                    <h5>状态</h5>

                    <div class="card-header-right">
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>

                <div class="card-block">
                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">状态</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.opportunity?.status?.name}</div>
                        </div>
                        <label class="col-md-2 col-form-label">失败原因</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.opportunity?.causeOfFailure?.name}</div>
                        </div>
                    </div>

                </div>

            </div>
            <div class="card">
                <div class="card-header">
                    <h5>定制字段</h5>

                    <div class="card-header-right">
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/flexFieldInstanceTemplate"/>
            </div>
            <div class="card">
                <div class="card-header">
                    <h5>笔记</h5>

                    <div class="card-header-right">
                        <g:link controller="note" action="create" params="[opportunity: this.opportunity?.id]" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/noteTemplate"/>
            </div>
            <div class="card">
                <div class="card-header">
                    <h5>拜访</h5>

                    <div class="card-header-right">
                        <g:link controller="activity" action="createAppointment" params="[opportunity: this.opportunity?.id]" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/appointmentTemplate"/>
            </div>
            <div class="card">
                <div class="card-header">
                    <h5>任务</h5>

                    <div class="card-header-right">
                        <g:link controller="activity" action="createTask" params="[opportunity: this.opportunity?.id]" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/taskTemplate"/>
            </div>
            <div class="card">
                <div class="card-header">
                    <h5>联系人</h5>

                    <div class="card-header-right">
                        <g:link controller="opportunityContact" action="create" params="[opportunity: this.opportunity?.id]" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <div class="card-block dt-responsive">

                    <div class="table-responsive">
                        <div id="dom-jqry_wrapper" class="dataTables_wrapper dt-bootstrap4">

                            <table class="table table-striped table-bordered table-hover">
                                <thead>
                                <tr>
                                    <g:sortableColumn property="contact" title="姓名"/>
                                    <g:sortableColumn property="connectedContact" title="关联人"/>
                                    <g:sortableColumn property="connectedType" title="关联人关系"/>
                                    <g:sortableColumn property="active" title="操作"/>
                                </tr>
                                </thead>
                                <tbody>
                                <g:each in="${com.next.OpportunityContact.findAllByOpportunity(this.opportunity)}">
                                    <tr>
                                        <td><g:link action="show" controller="contact" id="${it?.id}"
                                                    class="firstTd">${it?.contact?.fullName}</g:link></td>
                                        <td>${it?.connectedContact?.fullName}</td>
                                        <td>${it?.connectedType?.name}</td>
                                        <td class="text-center">
                                            <g:form resource="${it}" method="DELETE">
                                                <button class="deleteBtn btn btn-danger btn-outline-danger btn-mini" type="button">
                                                    <i class="icofont icofont-trash"></i> 删除</button>
                                            </g:form>
                                        </td>
                                    </tr>
                                </g:each>
                                </tbody>
                            </table>
                        </div>
                    </div>

                </div>


            </div>
            <div class="card">
                <div class="card-header">
                    <h5>团队</h5>

                    <div class="card-header-right">
                        <g:link controller="opportunityTeam" action="create" params="[opportunity: this.opportunity?.id]" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/teamTemplate"/>
            </div>
            <div class="card">
                <div class="card-header">
                    <h5>附件</h5>

                    <div class="card-header-right">
                        <g:link controller="attachment" action="create" params="[opportunity: this.opportunity?.id]" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/attachmentTemplate"/>
            </div>
            <div class="card">
                <div class="card-header">
                    <h5>工作流</h5>

                    <div class="card-header-right">
                        <g:link controller="workflowInstance" action="create" params="[opportunity: this.opportunity?.id]" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/workflowInstanceTemplate"/>
            </div>

            <div class="card">
                <div class="card-header">
                    <h5>修改历史</h5>

                    <div class="card-header-right">
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/opportunityHistoryTemplate"/>
            </div>            
        </div>

        <!-- Page-body end -->
    </div>
</div>

</body>

</html>
